/*
*   Copyright: Fabian Hajek (2012)  Programmieren: C   -   Semesterarbeit WS 2011/2012
*
*   Projekt: Schreinerei.exe
*
*   Author: $Author: webmaster@die-schwarzen-schwaben.de $
*
*   Name: main.c
*   URL:    $URL $
*
*   Description:   Gibt den Preis eines Schrankes zurueck
*
*   Last update:    $Date $
*
*   Rev:      $Rev: 56 $
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


/*INCLUDE input functions*/
#include "../default/structures.h"
#include "../Definitionen/define.h"
#include "func_price.h"

float get_price(SCHRANK *p_schrank)
{
    int i = 0;
    float price = 0;

    //Ressource-Kosten
    p_ressource = p_schrank->p_ressources[i];
    while(p_ressource)
    {
        if(p_ressource->entity != 'M' && p_ressource->entity != 'm') //Falls Stueckzahl erforderlich
        {
            price += p_ressource->price*p_schrank->ressources_quantity[i] / p_schrank->ressources_quantity[i];
        }
        else
        {
            price += p_ressource->price*p_schrank->ressources_quantity[i];

        }

        i++;
        p_ressource = p_schrank->p_ressources[i];
    }

    //AS-Kosten
    i = 0;
    p_step = p_schrank->p_steps[i];
    while(p_step)
    {
        price += p_step->price + p_schrank->steps_quantity[i];
        i++;
        p_step = p_schrank->p_steps[i];
    }

    //Gewinnzuschlag von PROFIT
    return price*PROFIT;
}
